local fenli = fk.CreateSkill {
  name = "lvshi__fenli",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable{
  ["lvshi__fenli"] = "奋砺",
  [":lvshi__fenli"] = "锁定技，回合结束时，你摸X张牌（X为你于本回合内造成伤害的属性数）。",
  ["#lvshi__fenli"] = "奋砺：你摸 %arg 张牌",

  ["$lvshi__fenli1"] = "奋励之志，在于立功。",
  ["$lvshi__fenli2"] = "厉兵秣马，以备寇贼。",
}

fenli:addEffect(fk.TurnEnd, {
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(fenli.name) and target == player then
      local damageTypes = {}
      player.room.logic:getActualDamageEvents(1, function (e)
        if e.data.from and e.data.from == player then
          local damageType = e.data.damageType or fk.NormalDamage
          table.insertIfNeed(damageTypes, damageType)
        end
      end, Player.HistoryTurn)
      if #damageTypes > 0 then
        event:setCostData(self, #damageTypes)
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(event:getCostData(self), fenli.name)
  end,
})

return fenli